<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateWechatKeys extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('wechat_keys',['engine'=>'InnoDB'])->setComment('微信-关键字');
        $table->addColumn(Column::string('appid',50)->setNullable()->setComment('公众号APPID'));
        $table->addColumn(Column::string('type',20)->setNullable()->setComment('类型(text,image,news)'));
        $table->addColumn(Column::string('keys',100)->setNullable()->setComment('关键字'));
        $table->addColumn(Column::text('content')->setNullable()->setComment('文本内容'));
        $table->addColumn(Column::string('image_url')->setNullable()->setComment('图片链接'));
        $table->addColumn(Column::string('voice_url')->setNullable()->setComment('语音链接'));
        $table->addColumn(Column::string('music_title')->setNullable()->setComment('音乐标题'));
        $table->addColumn(Column::string('music_image')->setNullable()->setComment('缩略图片'));
        $table->addColumn(Column::string('music_desc')->setNullable()->setComment('音乐描述'));
        $table->addColumn(Column::string('video_title')->setNullable()->setComment('视频标题'));
        $table->addColumn(Column::string('video_url')->setNullable()->setComment('视频URL'));
        $table->addColumn(Column::string('video_desc')->setNullable()->setComment('视频描述'));
        $table->addColumn(Column::bigInteger('news_id')->setNullable()->setComment('图文ID'));
        $table->addColumn(Column::bigInteger('sort')->setDefault(0)->setComment('排序字段'));
        $table->addColumn(Column::tinyInteger('status')->setDefault(1)->setComment('状态(0禁用,1启用)'));
        $table->addColumn(Column::bigInteger('create_by')->setDefault(0)->setComment('创建人'));
        $table->addTimestamps('create_at');
        $table->create();
    }
}
